<?php
/**
 * @version     1.0.1
 * @package     com_ganeshavereadores
 * @copyright  	
 * @license     
 * @author      Jorge Eduardo
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
JHtml::_('behavior.keepalive');

$filter_vereador = $_GET["filter-vereador"];



$db =& JFactory::getDBO();
$sql = 'SELECT distinct a.id, a.nome FROM #__ganeshavereadores_categoria a left join #__ganeshavereadores_proposicoes b on b.categoria=a.id where '; 

if($filter_vereador)
	$sql .= ' b.vereador='.$filter_vereador;
else
	$sql .= ' b.vereador=0';
	$sql .= ' order by a.nome ';
	
$db->setQuery($sql);
$categorialist[] = JHTML::_('select.option',  '0', JText::_( ' Selecione uma Atividade ' ), 'id', 'nome' );
$categorialist = array_merge( $categorialist, $db->loadObjectList() );
					?>	
					
	<?php foreach ($categorialist as $categoria) :?>
							<option value="<?php echo $categoria->id ?>"  <?php if($categoria->id == $filter_categoria) echo 'selected="true"'?>><?php echo $categoria->nome ?></option>						
						<?php endforeach;?>	